package com.haixiaoke.saas.enterprise.workOrder.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.haixiaoke.saas.common.annotation.Log;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.core.page.TableDataInfo;
import com.haixiaoke.saas.common.enums.BusinessType;
import com.haixiaoke.saas.common.utils.poi.ExcelUtil;
import com.haixiaoke.saas.system.BaseController;
import com.haixiaoke.saas.workOrder.domain.WorkOrderEvaluate;
import com.haixiaoke.saas.workOrder.service.IWorkOrderEvaluateService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;





/**
 * 工单评价Controller
 *
 * @author qixi
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/enterprise/workOrder/evaluate")
public class EnterpriseWorkOrderEvaluateController extends BaseController {
    @Autowired
    private IWorkOrderEvaluateService workOrderEvaluateService;

    /**
     * 查询工单评价列表
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkOrderEvaluate workOrderEvaluate) {
        startPage();
        List<WorkOrderEvaluate> list = workOrderEvaluateService.selectWorkOrderEvaluateList(workOrderEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出工单评价列表
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:export')")
    @Log(title = "工单评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkOrderEvaluate workOrderEvaluate) {
        List<WorkOrderEvaluate> list = workOrderEvaluateService.selectWorkOrderEvaluateList(workOrderEvaluate);
        ExcelUtil<WorkOrderEvaluate> util = new ExcelUtil<WorkOrderEvaluate>(WorkOrderEvaluate.class);
        util.exportExcel(response, list, "工单评价数据");
    }

    /**
     * 获取工单评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:query')")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") Long evaluateId) {
        return success(workOrderEvaluateService.selectWorkOrderEvaluateByEvaluateId(evaluateId));
    }

    /**
     * 新增工单评价
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:add')")
    @Log(title = "工单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkOrderEvaluate workOrderEvaluate) {
        return toAjax(workOrderEvaluateService.insertWorkOrderEvaluate(workOrderEvaluate));
    }

    /**
     * 修改工单评价
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:edit')")
    @Log(title = "工单评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkOrderEvaluate workOrderEvaluate) {
        return toAjax(workOrderEvaluateService.updateWorkOrderEvaluate(workOrderEvaluate));
    }

    /**
     * 删除工单评价
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:remove')")
    @Log(title = "工单评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable Long[] evaluateIds) {
        return toAjax(workOrderEvaluateService.deleteWorkOrderEvaluateByEvaluateIds(evaluateIds));
    }
}
